use warnings;
use Test::More 'no_plan';
use Inline C;

#1
$src = 0x80000001;
$dest = 0x40000001;
$dest_pan_id = 0x1001;
$handle = 0;
$en_ack = 1;
$en_indir = 0;
$user_data = 0x1211;
is(data_req_t($src, $dest, $dest_pan_id, $handle, $en_ack, $en_indir, $user_data), 0, 'test mac_data_req().');

#2
$src = 0x80000002;
$dest = 0x40000002;
$dest_pan_id = 0x1002;
$handle = 2;
$en_ack = 1;
$en_indir = 0;
$user_data = 0x1212;
is(data_req_t($src, $dest, $dest_pan_id, $handle, $en_ack, $en_indir, $user_data), 0, 'test mac_data_req().');

#3
$src = 0x80000003;
$dest = 0x40000003;
$dest_pan_id = 0x1003;
$handle = 3;
$en_ack = 1;
$en_indir = 1;
$user_data = 0x1213;
is(data_req_t($src, $dest, $dest_pan_id, $handle, $en_ack, $en_indir, $user_data), 0, 'test mac_data_req().');

#4
$src = 0x80000004;
$dest = 0x40000004;
$dest_pan_id = 0x1004;
$handle = 4;
$en_ack = 0;
$en_indir = 0;
$user_data = 0x1214;
is(data_req_t($src, $dest, $dest_pan_id, $handle, $en_ack, $en_indir, $user_data), 0, 'test mac_data_req().');

#5
$src = 0x80000005;
$dest = 0x40000005;
$dest_pan_id = 0x1005;
$handle = 5;
$en_ack = 0;
$en_indir = 0;
$user_data = 0x1215;
is(data_req_t($src, $dest, $dest_pan_id, $handle, $en_ack, $en_indir, $user_data), 0, 'test mac_data_req().');

#6
$src = 0x80000006;
$dest = 0x40000006;
$dest_pan_id = 0x1006;
$handle = 6;
$en_ack = 0;
$en_indir = 0;
$user_data = 0x1216;
is(data_req_t($src, $dest, $dest_pan_id, $handle, $en_ack, $en_indir, $user_data), 0, 'test mac_data_req().');




__END__
__C__

#include <stdio.h>
#include "../../../../mac/mac.h"

#include "mac_data_test.c"
#include "../../../../mac/mac_data.c"
#include "../../../../mac/mac_tx.c"
#include "../../../../mac/mac_gen.c"
#include "../../stub/mac_rf_stub.c"
#include "../../../../mac/mac_info.c"
#include "../../../../mac/mac_parse.c"
#include "../../../../mac/mac_retry.c"
#include "../../../../mac/mac_indir.c"
#include "../../../../mac/mem.c"
#include "../../../../mac/list.c"
#include "../../../../mac/buf.c"
#include "../../stub/timer_stub.c"
#include "../../../../mac/mac_phy.c"

/*
typedef struct mac_data_req_t_ {
    addr_t src;
    addr_t dest;
    pan_id_t dest_pan_id;
    uint8 handle;
    //uint8 options;
    mac_options_t opt;
} mac_data_req_t;
*/

int data_req_t(unsigned int src, unsigned int dest, unsigned short dest_pan_id,
               unsigned char handle, unsigned char en_ack, unsigned char en_indir,
               unsigned short user_data)
{
    mac_data_req_t req;
    mac_options_t opt;

    mac_init_test();

    MAC_DEBUG("data_req_t: 1\n");
    req.src.mode = ADDR_64_M;
    req.src.a.addr64 = src;
    req.dest.mode = ADDR_64_M;
    req.dest.a.addr64 = dest;
    req.dest_pan_id = dest_pan_id;
    req.handle = handle;

    MAC_DEBUG("data_req_t: 2\n");
    opt.gts = 0;
    opt.ack = en_ack ? 1 : 0;
    opt.indir = en_indir ? 1 : 0;

    MAC_DEBUG("data_req_t: 3\n");
    req.opt = opt;
    MAC_DEBUG("data_req_t: 4\n");

    fflush(stdout);
    return mac_data_req_test(&req, user_data);
}

